<?php
/**
 * Created by PhpStorm.
 * User: 王峥宇
 * Date: 2019-04-30
 * Time: 1:58
 */

namespace app\admin\model;


use think\Session;

class Setup extends BaseModel
{
    public static function getSetup(){
        $gid = Session::get('admin_uid');
        $id = new Guanli();
        $id = $id->where('id',$gid)->find();
        $set = self::where('uid',$id['uid'])->find();
        if($set == ''){
            if (request()->isAjax()) {
                $data['blank'] = input('blank');
                $data['weixin'] = input('weiin');
                $data['zhifubao'] = input('zhifubao');
                $data['uid'] = $id['uid'];
                $se = self::insert($data);
                if ($se){
                    return 1;
                }else{
                    return 0;
                }
            }
        }else{
            if (request()->isAjax()) {
                $data['blank'] = input('blank');
                $data['weixin'] = input('weiin');
                $data['zhifubao'] = input('zhifubao');
                $up = self::where('id',$id['id'])->update($data);
                if($up){
                    return 1;
                }else{
                    return 2;
                }
            }
        }
        return $set;
    }
}